package com.mhy.robot

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.mhy.dingrobot.Robot
import com.mhy.robot.databinding.ActivityMainBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val viewBinding= ActivityMainBinding.inflate(layoutInflater)
        setContentView(viewBinding.root)
        viewBinding.dingding.setOnClickListener {
           val dRobot= Robot("")
          val  result= dRobot.sendLinkMsg("https://baidu.com","","true","hhhhhhhhhhh")
            viewBinding.dingding.text=result.toString()
        }
        viewBinding.weCom.setOnClickListener {
            val wRobot=com.mhy.wxrobot.Robot("")
            lifecycleScope.launch {
              val result=  withContext(Dispatchers.IO){
                    wRobot.sendTextMsg("hahahha", arrayListOf(),true)
                }
                viewBinding.weCom.text=result.toString()
            }

        }
    }

}